from flask import Blueprint
from flask_restful import Api

from .user_resources import (
    AddUserResource, SearchResource, DeleteImageResource, GetUserFileListResource, GetExcelDataResource,
    GetFilesResource, GetFileResource, SubmitAnnotationResource, GetImageResource,
    SaveAnnotationResource, SavePatientResource, )

from .admin_resources import (
    GetFileListResource, UpdateUserResource, DeleteUserResource, UploadFileResource, CreateFolderResource,
    DownloadFileResource, DeleteFileResource, UpdatePasswordResource, LoginResource, TestResource,SendFileResource)


bp = Blueprint("restapi", __name__, url_prefix="/api/v1")
api = Api(bp)

def init_app(app):
    # 管理员接口
    api.add_resource(DeleteUserResource, '/delete_user')
    api.add_resource(GetFileListResource, '/GetFileList')
    api.add_resource(UpdateUserResource, '/update_user')
    api.add_resource(CreateFolderResource, '/CreateFolder')
    api.add_resource(UploadFileResource, '/UploadFile')
    api.add_resource(DeleteFileResource, '/DeleteFile')
    api.add_resource(DownloadFileResource, '/DownloadFile')
    api.add_resource(SendFileResource, '/SendFile')
    api.add_resource(UpdatePasswordResource, '/update_password')
    api.add_resource(LoginResource, '/login')
    api.add_resource(TestResource, '/test')

    # 用户接口
    api.add_resource(AddUserResource, '/Adduser')
    api.add_resource(SearchResource, '/Search')
    api.add_resource(GetImageResource, '/GetImage')
    api.add_resource(DeleteImageResource, '/DeleteImage')
    api.add_resource(GetUserFileListResource, '/GetUserFileList')
    api.add_resource(GetFilesResource, '/getFiles')
    api.add_resource(GetFileResource, '/getFile')
    api.add_resource(SubmitAnnotationResource, '/submitAnnotation')
    api.add_resource(SaveAnnotationResource, '/saveAnnotation')
    api.add_resource(SavePatientResource, '/savePatient')
    api.add_resource(GetExcelDataResource, '/getExcelData')

    app.register_blueprint(bp)
